/*
 * Поиск подстроки
 */

#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MIN(a, b)	((a) < (b) ? (a) : (b))


#ifdef DEBUG
# define debug_fprintf(x)	fprintf x
#else
# define debug_fprintf(x)	((void) 0)
#endif

#define S_assert(st) ((st)?((void)0):(void)fprintf(stderr,"Assertion (soft) \"%s\" in %s:%s():%d: failed.\n",#st,__FILE__,__func__,__LINE__))
#define SWAP_INT(a, b)	(((a) ^ (b)) && ((b) ^= (a) ^= (b), (a) ^= (b)))

/* autoarray */
struct vector {
	char *data;
	size_t _elem_size;

	int n;
	int _max;
};

/* {{{ memory allocation wrappers */
extern char *
s_calloc(size_t n, size_t size)
{
	void *ptr;
#ifdef MEMDEBUG
	fprintf(stderr, "%s(): calloc %lu times %lu bytes (tot %.4f MiB)\n",
			__func__, n, size, ((float) n * size) / (1024.0f * 1024.0f));
#endif /* MEMDEBUG */
	ptr = calloc(n, size);
	if (ptr == NULL) {
		fprintf(stderr, "%s(): out of memory, failed to allocate %lu bytes\n",
				__func__, n * size);
		abort();
	}
	return ptr;
}

extern char *
s_malloc(size_t size)
{
	void *ptr;
#ifdef MEMDEBUG
	fprintf(stderr, "%s(): malloc %lu bytes (%.4f MiB)\n",
			__func__, size, (float) size / (1024.0f * 1024.0f));
#endif /* MEMDEBUG */
	ptr = malloc(size);
	if (ptr == NULL) {
		fprintf(stderr, "%s(): out of memory, failed to allocate %lu bytes\n",
				__func__, size);
		abort();
	}
	return ptr;
}

extern char *
s_realloc(char *oldptr, size_t newsize)
{
	void *newptr;
#ifdef MEMDEBUG
	fprintf(stderr, "%s(): realloc oldptr %p for new size of %lu (%.4f MiB)\n",
			__func__, oldptr, newsize, (float) newsize / (1024.0f * 1024.0f));
#endif
	newptr = realloc(oldptr, newsize);
	if (newptr == NULL) {
		fprintf(stderr, "%s(): out of memory, "
				"failed to realloc %p for new size of %lu bytes\n",
				__func__, oldptr, newsize);
		abort();
	}
#ifdef MEMDEBUG
	fprintf(stderr, "%s(): newptr %p\n", __func__, newptr);
#endif /* MEMDEBUG */
	return newptr;
}
/* }}} */

/* {{{ autoarray */
extern struct vector *
vector__new(size_t elem_size, int p)
{
	struct vector *v = NULL;

	if (p < 0)
		p = 0;

	v = (struct vector *) s_malloc(sizeof *v);
	v->_max = 1 << p;
	v->_elem_size = elem_size;
	v->n = 0;
	v->data = (char *) s_calloc((size_t) v->_max, v->_elem_size);

	return v;
}

extern int
vector__append(struct vector *v, const void *app)
{
	int ret = 0;

	if (v == NULL) {
		fprintf(stderr, "%s(): received NULL ptr, not doing anything (-1)\n",
				__func__);
		return -1;
	}

	if (v->_max == 0) {
		/* weird input, fix it */
		ret |= 2;
		debug_fprintf((stderr, "%s(): v->_max is 0, which means that your "
					"autoarray (v=%p) is messed up. trying to fix this.\n",
					__func__, (void*) v));
		if (v->_elem_size == 0) {
			ret |= 4;
			fprintf(stderr, "%s(): can't fix this mess, bailing out (%d)\n",
					__func__, ret);
			return ret;
		} else {
			v->_max = 1;
			v->n = 0;
			v->data = (char *) s_calloc((size_t) v->_max, v->_elem_size);
		}
	}

	if (v->n + 1 >= v->_max) {
		v->data = (char *) s_realloc(v->data, v->_elem_size * (v->_max *= 2));
	}
	memcpy(v->data + (v->n++) * v->_elem_size, app, v->_elem_size);

	return ret;
}

extern char *
vector__get_by_idx(struct vector *v, const int idx)
{
	if (v == NULL) {
		fprintf(stderr, "%s(): received NULL ptr, not doing anything (NULL)\n",
				__func__);
		return NULL;
	}

	if (v->_elem_size == 0) {
		fprintf(stderr, "%s(): whoah, looks like your vector is messed up big time (NULL)\n",
				__func__);
		return NULL;
	}

	if (idx < 0 || idx >= v->n) {
		fprintf(stderr, "%s(): index out of range %d (v->n=%d)\n",
				__func__, idx, v->n);
		return NULL;
	}

	return v->data + (idx) * v->_elem_size;
}

extern int
vector__cleanup(struct vector *v)
{
	int ret = 0;

	if (v == NULL) {
		fprintf(stderr, "%s(): received NULL ptr, not doing anything (-1)\n",
				__func__);
		return -1;
	}

	if (v->_max > 0) {
		v->_max = v->n = 0;
		free(v->data);
		v->data = NULL;
	} else {
		ret |= 1;
	}

	/* TODO: improve logic */
	debug_fprintf((stderr, "%s(): freeing v=%p\n", __func__, (void*) v));
	free(v);

	return ret;
}
/* }}} */

void
print_transitions_table(const int **tr)
{
}

/**
 * true if P[0, k) is suffix of P[0, i) + c
 * false otherwise
 */
static int
condition(const char *P, const int i, const int k, const int c)
{
	char *buf;
	int ans;

	/* k <= i + 1 by definition (see caller map) */
	S_assert(k <= i + 1);

	buf = s_malloc(i + 2UL);
	strncpy(buf, P, i);
	buf[i] = c;
	buf[i + 1] = '\0';

	ans = !strncmp(P, buf + strlen(buf) - k, k);
	free(buf);
	return ans;
}

int **
compute_transitions_func(const char *P)
{
	int **tr;
	size_t len = 0UL;
	register short i = 0, c = 'a', k;

	assert(P != NULL);
	len = strlen(P);
	tr = s_calloc(len + 1, sizeof *tr);
	for (i = 0; i <= len; i++)
		tr[i] = s_calloc('z' - 'a' + 1, sizeof **tr);

	for (i = 0; i <= len; i++) {
		for (c = 'a'; c < 'z' + 1; c++) {
			k = MIN(i + 1, len);
			while (k > 0 && !condition(P, i, k, c))
				k--;
			tr[i][c - 'a'] = k;
		}
	}

	return tr;
}

int
dfa_strstr(const char *T, const char *P, const int **tr, struct vector *ans)
{
	int q = 0, i = 0;
	size_t lenT, lenP;
	int tmp;
	int ret = 0;

	lenT = strlen(T);
	lenP = strlen(P);

	for (i = 0; i < lenT; i++) {
		q = tr[q][T[i] - 'a'];
		if (q == lenP) {
			tmp = i - lenP + 1;
			vector__append(ans, &tmp);
			ret++;
		}
	}

	return ret;
}

int
main(int argc, char **argv)
{
	static char P[102], T[200002];
	int **transitions;
	struct vector *ans;
	int i;

	ans = vector__new(sizeof (int), 0);
	scanf("%s %s", P, T);
	transitions = compute_transitions_func(P);

	if (dfa_strstr(T, P, transitions, ans) > 0) {
		printf("%d\n", ans->n);
		for (i = 0; i < ans->n; i++)
			printf("%d ", *(int*)vector__get_by_idx(ans, i));
		putchar('\n');
	} else {
		fputc('0', stdout);
		fputc('\n', stdout);
	}

	for (i = strlen(P); i >= 0; i--)
		free(transitions[i]);
	free(transitions);
	vector__cleanup(ans);

	return 0;
}
